#ifndef PROPERTY_H
#define PROPERTY_H
#include <qstringlist.h>
#include <qjsonobject.h>
#include "Def.h"

class SDK_EXPORT_API Property : public INamedObject
{
public:
	static const int TypeNill = -1;
	static const int TypeInt = 0;
	static const int TypeDouble = 1;
	static const int TypeBoolean = 2;
	static const int TypeString = 3;

	static Property fromJson(const QJsonObject& object);

	Property();
	Property(const Property& other);
	Property(const char* data,const QString& name,const QString& desc = QString());
	Property(int value,const QString& name,const QString& desc = QString());
	Property(double value,const QString& name,const QString& desc = QString());
	Property(bool value,const QString& name,const QString& desc = QString());
	Property(const QString& value,const QString& name,const QString& desc = QString());
	~Property();
public:
	int asInt()const;
	double asDouble()const;
	bool asBoolean()const;
	QString getString()const;

	int getValueType()const { return valueType; }
	const QString getName()const{return valueName;}
	const QString getDesciption()const{return valueDescription;}
	QJsonObject toJson()const;
private:
	int valueInt = 0;
	double valueDouble = 0.0;
	bool valueBoolean = false;
	QString valueString;
	int valueType = TypeNill;
	QString valueName;
	QString valueDescription;
};

class IPropertySet
{
public:
	virtual bool containProperty(const QString& key) = 0;

	virtual void setProperty(const Property& property) = 0;
	virtual Property getProperty(const QString& key)const = 0;
	virtual QStringList getPropertyNameList()const = 0;
};

#endif
